# config.py
import os
from pathlib import Path
from dotenv import load_dotenv

load_dotenv()

class Config:
    # Redis配置
    REDIS_HOST = os.getenv("REDIS_HOST", "192.168.0.99")
    REDIS_PORT = int(os.getenv("REDIS_PORT", 6379))
    REDIS_DB = int(os.getenv("REDIS_DB", 10))
    Result_DB = int(os.getenv("REDIS_DB", 11))

    # 摄像头配置
    CAMERAS = {
        "area1": {
            "url": "rtmp://192.168.12.20/live/34020000002000001031",
            "location": "LY-ZSZX-031",
            "stream_url": "rtmp://192.168.12.20/live/34020000002000001031"
        },
        "area2": {
            "url": "rtmp://192.168.12.20/live/34020000002000001017",
            "location": "LY-ZSZX-017",
            "stream_url": "rtmp://192.168.12.20/live/34020000002000001017"
        },
        "area3": {
            "url": "rtmp://192.168.12.20/live/34020000002000001016",
            "location": "楼外-东-16",
            "stream_url": "rtmp://192.168.12.20/live/34020000002000001016"
        }
    }

    # 预警接口配置
    ALARM_API = {
        "endpoint": "http://192.168.0.99:28100/smart_site_management/site_alarm",
        "types": {
            "持械": 20,
            "火患": 100,
            "打斗": 10,
            "人员": 30,
            "动物": 60,
            "徘徊": 80
        },
        "levels": {
            "持械": 1,
            "火患": 1,
            "打斗": 1,
            "人员": 2,
            "动物": 3,
            "徘徊": 2
        }
    }

    # 消息模板
    MESSAGE_TEMPLATES = {
        "持械": "{location}发现持械行为（置信度{confidence:.0%}）",
        "火患": "{location}发现火情隐患（置信度{confidence:.0%}）",
        "打斗": "{location}发生打架斗殴（置信度{confidence:.0%}）",
        "人员": "{location}发现非法闯入（置信度{confidence:.0%}）",
        "动物": "{location}发现动物闯入（置信度{confidence:.0%}）",
        "徘徊": "{location}发现人员徘徊（置信度{confidence:.0%}）"
    }

    # 文件存储
    FRAME_SAVE_DIR = Path("alarm_frames")
    FRAME_SAVE_DIR.mkdir(exist_ok=True)